<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>用户注册-会员中心-初来这里网</title>
</head>
<body>
	<div>
		<form action="{:U(GROUP_NAME.'/Member/runReg')}" method="post" onsubmit="return check();">
			<table>
				<tr>
					<td width="20%" align="right"><label for="member_name">用&nbsp;户&nbsp;名：</label></td>
					<td width="40%"><input id="member_name" type="text" name="uname" size="40" /></td>
					<td width="40%"><span id='member_name_span'></span></td>
				</tr>
				<tr>
					<td align="right"><label for="member_pwd">密&nbsp;&nbsp;&nbsp;&nbsp;码：</label></td>
					<td><input id="member_pwd" type="password" name="pwd" size="40" /></td>
					<td><span id='member_pwd_span'></span></td>
				</tr>
				<tr>
					<td align="right"><label for="member_pwd">确认密码：</label></td>
					<td><input id="member_repwd" type="password" name="repwd" size="40" /></td>
					<td><span id='member_repwd_span'></span></td>
				</tr>
				<tr>
					<td align="right"><label for="member_email">邮&nbsp;&nbsp;&nbsp;&nbsp;箱：</label></td>
					<td><input id="member_email" type="text" name="email" size="40" /></td>
					<td><span id='member_email_span'></span></td>
				</tr>
				<tr>
					<td align="right"><label for="member_verify">验&nbsp;证&nbsp;码：</label></td>
					<td><input type="text" name="member_verify" id="member_verify" size="30" /> <img id="member_verify_img" style="cursor:pointer;" src="{:U(GROUP_NAME."/Member/verify")}"  onClick="this.src=this.src+'?'+Math.random()" alt="验证码" /><span style="cursor:pointer;" id="member_verify_kbq">看不清刷新</span></td>
					<td><span id='member_verify_span'></span></td>
				</tr>
				
				<tr align="center">
					<td width="60%" colspan="3"><input type="submit" value="提交" /> <input type="reset" value="重置" /></td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>
<script>

	function trim(str){ //删除左右两端的空格
	return str.replace(/(^\s*)|(\s*$)/g, "");
	} 
		var member_name=document.getElementById('member_name');
		var member_pwd=document.getElementById('member_pwd');
		var member_repwd=document.getElementById('member_repwd');
		var member_email=document.getElementById('member_email');
		var member_verify=document.getElementById('member_verify');

		var member_name_span=document.getElementById('member_name_span');
		var member_pwd_span=document.getElementById('member_pwd_span');
		var member_repwd_span=document.getElementById('member_repwd_span');
		var member_email_span=document.getElementById('member_email_span');
		var member_verify_span=document.getElementById('member_verify_span');
		var member_verify_kbq=document.getElementById('member_verify_kbq');
		var member_verify_img=document.getElementById('member_verify_img');

					
		// 验证用户名开始
		member_name.onfocus=function(){
			member_name_span.innerHTML='必须以字母开头，只能包含字母、数字和下划线，5-18个字符';
		}
		member_verify_kbq.onclick=function(){
			member_verify_img.src=member_verify_img.src+'?'+Math.random()
		}

		member_name.onblur=function(){
			var member_name_value=member_name.value;
			member_name_value=trim(member_name_value);
			// alert(member_name_value);
			var reg=/^[a-zA-Z]\w{4,17}$/;
			var stat=reg.test(member_name_value);
			// alert(stat);
			if (stat) {
				member_name_span.innerHTML='<img src="__PUBLIC__/Images/duihao.png" alt="" />';
			}else{
				member_name_span.innerHTML='<img src="__PUBLIC__/Images/cuohao.png" alt="" />必须以字母开头，只能包含字母、数字和下划线，5-18个字符';
			};
		}
		member_name.onclick=function(){
			var member_name_value=member_name.value;
			member_name_value=trim(member_name_value);
			if (member_name_value=='') {
				member_name_span.innerHTML='必须以字母开头，只能包含字母、数字和下划线，5-18个字符';
			}else{
			// alert(member_name_value);
			var reg=/^[a-zA-Z]\w{4,17}$/;
			var stat=reg.test(member_name_value);
			// alert(stat);
			if (stat) {
				member_name_span.innerHTML='<img src="__PUBLIC__/Images/duihao.png" alt="" />';
			}else{
				member_name_span.innerHTML='<img src="__PUBLIC__/Images/cuohao.png" alt="" />必须以字母开头，只能包含字母、数字和下划线，5-18个字符';
			};
			};
		}
		// 验证用户名结束

		// 验证密码开始
		member_pwd.onfocus=function(){
			member_pwd_span.innerHTML='必须以字母开头，只能包含字母、数字和下划线，5-18个字符';
		}
		member_pwd.onblur=function(){
			var member_pwd_value=member_pwd.value;
			trim(member_pwd_value);
			// alert(member_name_value);
			var reg=/^[a-zA-Z]\w{4,17}$/;
			var stat=reg.test(member_pwd_value);
			// alert(stat);
			if (stat) {
				member_pwd_span.innerHTML='<img src="__PUBLIC__/Images/duihao.png" alt="" />';
			}else{
				member_pwd_span.innerHTML='<img src="__PUBLIC__/Images/cuohao.png" alt="" />必须以字母开头，只能包含字母、数字和下划线，5-18个字符';
			};
		}
		member_pwd.onclick=function(){
			// alert(11);
			var member_pwd_value=member_pwd.value;
			member_pwd_value=trim(member_pwd_value);
			// alert(member_pwd_value);
			if (member_pwd_value=="") {
				// alert(member_pwd_value);
				member_pwd_span.innerHTML='必须以字母开头，只能包含字母、数字和下划线，5-18个字符';
			}else{
			var reg=/^[a-zA-Z]\w{4,17}$/;
			var stat=reg.test(member_pwd_value);
			// alert(stat);
			if (stat) {
				member_pwd_span.innerHTML='<img src="__PUBLIC__/Images/duihao.png" alt="" />';
			}else{
				member_pwd_span.innerHTML='<img src="__PUBLIC__/Images/cuohao.png" alt="" />必须以字母开头，只能包含字母、数字和下划线，5-18个字符';
			};
			};
		}
		// 验证密码结束
		// 验证确认密码开始
		member_repwd.onfocus=function(){
			// alert(66);
			member_repwd_span.innerHTML='必须以字母开头，只能包含字母、数字和下划线，5-18个字符';
		}
		member_repwd.onblur=function(){
			var member_repwd_value=member_repwd.value;
			trim(member_repwd_value);
			// alert(member_name_value);
			var reg=/^[a-zA-Z]\w{4,17}$/;
			var stat=reg.test(member_repwd_value);
			// alert(stat);
			if (stat) {
				member_repwd_span.innerHTML='<img src="__PUBLIC__/Images/duihao.png" alt="" />';
			}else{
				member_repwd_span.innerHTML='<img src="__PUBLIC__/Images/cuohao.png" alt="" />必须以字母开头，只能包含字母、数字和下划线，5-18个字符';
			};
			if (member_pwd.value!=member_repwd.value) {
				alert("2次输入密码不一致");
				member_repwd_span.innerHTML='<img src="__PUBLIC__/Images/cuohao.png" alt="" />2次输入密码不一致';
			};
		}
		
		// 验证确认密码结束

		// 验证邮箱开始
		member_email.onfocus=function(){
			// alert(66);
			member_email_span.innerHTML='请输入一个合法的邮箱，例如：12345@qq.com  12345@163.com等';
		}
		member_email.onblur=function(){
			var member_email_value=member_email.value;
			trim(member_email_value);
			var reg=/^[a-zA-Z0-9]\w+@[a-zA-Z0-9]+\.(com|cn|com.cn|net|org|cc)$/;
			var stat=reg.test(member_email_value);
			if (stat) {
				member_email_span.innerHTML='<img src="__PUBLIC__/Images/duihao.png" alt="" />';
			}else{
				member_email_span.innerHTML='<img src="__PUBLIC__/Images/cuohao.png" alt="" />请输入一个合法的邮箱，例如：12345@qq.com  12345@163.com等';
			};
		}

		// 验证验证码开始
		member_verify.onfocus=function(){
			// alert(66);
			member_verify_span.innerHTML='请输入验证码';
		}
		member_verify.onblur=function(){
			var member_verify_value=member_verify.value;
			trim(member_verify_value);
			var reg=/^[0-9]{4,4}$/;
			var stat=reg.test(member_verify_value);
			if (stat) {
				member_verify_span.innerHTML='';
			}else{
				member_verify_span.innerHTML='<img src="__PUBLIC__/Images/cuohao.png" alt="" />请输入正确的验证码';

			};
		}

	function check(){
		if (member_name.value=='') {alert('用户名不能空');return false;}else{
			var member_name_value=member_name.value;
			member_name_value=trim(member_name_value);
			var reg=/^[a-zA-Z]\w{4,17}$/;
			var stat=reg.test(member_name_value);
			// alert(stat);
			if (!stat) {
				alert('用户名必须以字母开头，只能包含字母、数字和下划线，5-18个字符');return false;
			};
		};
		if (member_pwd.value=='') {alert('密码不能空');return false;}else{
			var member_pwd_value=member_pwd.value;
			trim(member_pwd_value);
			// alert(member_name_value);
			var reg=/^[a-zA-Z]\w{4,17}$/;
			var stat=reg.test(member_pwd_value);
			// alert(stat);
			if (!stat) {
				alert('密码必须以字母开头，只能包含字母、数字和下划线，5-18个字符');return false;
			};
		};
		if (member_repwd.value=='') {alert('确认密码不能空');return false;}else{
			var member_repwd_value=member_repwd.value;
			trim(member_repwd_value);
			// alert(member_name_value);
			var reg=/^[a-zA-Z]\w{4,17}$/;
			var stat=reg.test(member_repwd_value);
			// alert(stat);
			if (!stat) {
				alert('确认密码必须以字母开头，只能包含字母、数字和下划线，5-18个字符');return false;
			};
			if (member_pwd.value!=member_repwd.value) {
				
				member_repwd_span.innerHTML='<img src="__PUBLIC__/Images/cuohao.png" alt="" />2次输入密码不一致';
				alert("2次输入密码不一致");return false;
			};
		};
		if (member_email.value=='') {alert('邮箱不能空');return false;}else{
			var member_email_value=member_email.value;
			trim(member_email_value);
			var reg=/^[a-zA-Z0-9]\w+@[a-zA-Z0-9]+\.(com|cn|com.cn|net|org|cc)$/;
			var stat=reg.test(member_email_value);
			if (!stat) {
				alert('请输入一个合法的邮箱，例如：12345@qq.com 12345@163.com等');return false;
			};
		};
		if (member_verify.value=='') {alert('验证码不能空');return false;}else{
			var member_verify_value=member_verify.value;
			trim(member_verify_value);
			var reg=/^[0-9]{4,4}$/;
			var stat=reg.test(member_verify_value);
			if (!stat) {
				alert('请输入正确的验证码');return false;
			};
		};

		return true;
	}
</script>

